package com.atXiao.cloud.service.impl;

import com.atXiao.cloud.service.IMessageProvider;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.support.MessageBuilder;

import javax.annotation.Resource;
import java.util.UUID;

@EnableBinding(Source.class)
public class MessageProviderImpl implements IMessageProvider {

    @Resource
    MessageChannel output;

    @Override
    public String send() {
        //模拟订单号
        String msg= UUID.randomUUID().toString();
        boolean flag = output.send(MessageBuilder.withPayload(msg).build());
        if (flag){
            System.out.println("消息发送成功~~~~,消息内容为："+msg);
        }else{
            System.out.println("消息发送失败:<");
        }
        return null;
    }
}
